package com.design.pattern.behaviour.strategy;

/**
 * @Author hanyuanlai
 * @Date 2022/7/12
 */
public class CashContext {
    private CashSuper cashSuper;

    public CashContext(String type) {
        switch (type) {
            case "discount":
                cashSuper = new CashDiscount();
                break;
            case "return":
                cashSuper = new CashReturn();
            default:
                cashSuper = new CashNormal();
        }
    }

    public double getResult(double cash) {
        return cashSuper.acceptCash(cash);
    }
}
